﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pata.SylkSharp.Core.Bll
{
    /// <summary>
    /// Enumerates the possible fields in a <see cref="FRecord"/>
    /// </summary>
    public enum FRecordFieldType
    {
        /// <summary>
        /// column (one based)
        /// </summary>
        X,
        /// <summary>
        /// Column (one based)
        /// </summary>
        C,

        /// <summary>
        /// row (one based)
        /// </summary>
        Y,
        /// <summary>
        /// Row (one based)
        /// </summary>
        R,

        /// <summary>
        /// Format
        /// </summary>
        F,

        /// <summary>
        /// Default format
        /// </summary>
        D,

        /// <summary>
        /// Show formulas
        /// </summary>
        E,

        /// <summary>
        /// Show commas
        /// </summary>
        K,

        /// <summary>
        /// Column width
        /// </summary>
        W,

        /// <summary>
        /// Font
        /// </summary>
        N,

        /// <summary>
        /// Index
        /// </summary>
        P,

        /// <summary>
        /// Style
        /// </summary>
        S,

        /// <summary>
        /// Defines that headers must be (H)idden
        /// </summary>
        H,

        /// <summary>
        /// Defines that gridlines must be absent
        /// </summary>
        G,
        /// <summary>
        /// Unknown field type.
        /// </summary>
        Unknown = 100
    }

    /// <summary>
    /// Object representation of field of a Sylk record of type 'F'
    /// </summary>
    public class FRecordField : FieldBase<FRecordFieldType>
    {
        /// <summary>
        /// Instanciate a new <see cref="FRecordField"/>
        /// </summary>
        public FRecordField()
            : base(FRecordFieldType.Unknown, String.Empty) { }

        /// <summary>
        /// Instanciate a new <see cref="FRecordField"/>
        /// </summary>
        /// <param name="pType">Type of this field.</param>
        /// <param name="pValue">The value contained by this field.</param>
        public FRecordField(FRecordFieldType pType, string pValue)
            : base(pType, pValue) { }
    }

    /// <summary>
    /// Object representation of a Sylk record of type 'F'.
    /// </summary>
    public class FRecord : RecordBase<FRecordField, FRecordFieldType>
    {
        private static readonly FRecordFieldType[] _MANDATORY_FIELDS = new FRecordFieldType[] { };

        /// <summary>
        /// Instanciate a new <see cref="FRecord"/>
        /// </summary>
        public FRecord(string pLineWithoutId)
            : base(RecordType.F, pLineWithoutId, FRecordFieldType.Unknown) { }

        /// <summary>
        /// Get mandatory fields for this record.
        /// </summary>
        /// <returns></returns>
        public override System.Collections.Generic.IEnumerable<FRecordFieldType> GetMandatoryFields()
        {
            return _MANDATORY_FIELDS;
        }

        //TODO:Add here accessors or methods to Get/Set specific values for this FRecordField

        /// <summary>
        /// Get the default field type.
        /// </summary>
        /// <returns></returns>
        public override FRecordFieldType GetUnknownFieldType()
        {
            return FRecordFieldType.Unknown;
        }
    }
}
